home *** CD-ROM | disk | FTP | other *** search
/ Plug-In Power Pack for Netscape Communicator / Plug-In Power Pack for Netscape Communicator.iso / plugins / dataviews / include / std.h < prev    next >
C/C++ Source or Header  |  1997-05-08  |  10KB  |  423 lines

  1. /* file -- std.h
  2. |======================================================================
  3. |
  4. |    @(#)std.h    V2.109
  5. |
  6. |              copyright (c) 1988-92, V.I. Corporation
  7. |
  8. |    std.h -- standard include file for DataViews
  9. |
  10. |=====================================================================
  11. */
  12. #ifndef    _STD_H_
  13. #define    _STD_H_
  14.  
  15. #include <stdio.h>
  16. #include "dvenv.h"
  17.  
  18. #ifdef WINNT
  19. #include <windows.h>
  20. #endif
  21.  
  22. /* Only use function prototypes with ANSI C and C++ */
  23. /* The V_P_ macro hides the function prototypes */
  24. #if defined(ANSIFY) || (( defined(__STDC__) || defined(__cplusplus) ) && ! defined(_NO_PROTO))
  25. # define V_P_(s) s
  26. #else
  27. # define V_P_(s) ()
  28. #endif
  29.  
  30. #if defined (DV_DEV_COMP) && ( defined (__STDC__) || defined (__cplusplus) )
  31. /* eliminate "used before initialized" messages from ansi c */
  32. # define DV_INIT(a, b) (a) = (b)
  33. /* eliminate "value computed is not used" messages from ansi c */
  34. # define DV_ASSIGN(a, b) (a) = b
  35. /* eliminate "defined but unused" messages from ansi c for SccsId */
  36. # define VI_USE(var) static void * use_##var = (&use_##var, (void *) &var)
  37. VI_USE (SccsId);
  38. #else
  39. # define DV_INIT(a, b)
  40. # define DV_ASSIGN(a, b)
  41. #endif /* __STDC__ */
  42.  
  43. #if ( defined(__STDC__) || defined(__cplusplus) ) && ! defined(_NO_PROTO)
  44. #include <sys/types.h>    /* for fd_set */
  45.  
  46. #ifdef WINNT
  47. #include <time.h>
  48. #else
  49. #include <sys/time.h>    /* for struct timeval */
  50. #endif
  51.  
  52. #include <setjmp.h>    /* for jmp_buf */
  53. #endif
  54.  
  55.  
  56. /* We don't want to include math.h with Visual C++ as it causes 
  57.  * multiple link errors.
  58.  */
  59. #if ! defined(WINNT) || ! defined(__cplusplus)
  60. #include <math.h>
  61. #endif
  62.  
  63. #ifdef HAS_STRING_H
  64. #include <string.h>
  65. #endif
  66.  
  67. #ifdef HAS_STRINGS_H
  68. #include <strings.h>
  69. #endif
  70.  
  71.  
  72. #if defined(__STDC__)
  73. #include <stdarg.h>
  74. #else
  75. #include <varargs.h>
  76. #endif
  77.  
  78. #if defined(HAS_STDLIB)
  79. #include <stdlib.h>
  80. #endif
  81.  
  82. /* storage classes */
  83. #define FAST register
  84.  
  85. #ifndef VMS
  86. #if defined( WINNT ) && ( !defined( WINNT_NODVDLL) )
  87. #define GLOBALDEF __declspec(dllexport)
  88. #define GLOBALREF __declspec(dllimport)
  89. #else
  90. #define GLOBALDEF 
  91. #define GLOBALREF extern
  92. #endif
  93. #else
  94. #define GLOBALDEF globaldef
  95. #define GLOBALREF globalref
  96. #endif
  97.  
  98. #define LOCAL static
  99. #define CONST const
  100.  
  101. #ifndef VI
  102. #define VI    /* Declares functions to be internal VI routines */
  103. #endif
  104.  
  105. /* Data types */
  106. typedef char CHAR;        
  107.  
  108. typedef char DV_BOOL;         
  109. typedef long BOOL_FUN;         
  110. typedef double DOUBLE;        
  111. typedef long LONG;        
  112. #ifdef HPUX_8          /* Get rid of existing define (from <sys/types.h>?) */
  113. #undef FLOAT
  114. #endif
  115. typedef float FLOAT;        
  116. typedef int INT;         
  117. typedef int ENUM;         
  118. #define VOID void
  119. typedef short SHORT;         
  120.  
  121. #ifdef __STDC__
  122. typedef char *ADDRESS;    /* was void *ADDRESS;  but this is too lenient */
  123. #else
  124. typedef char *ADDRESS;    
  125. #endif
  126.  
  127. #ifdef __STDC__
  128. typedef int BOOLPARAM;
  129. typedef int UBYTEPARAM;
  130. #else
  131. typedef DV_BOOL BOOLPARAM;         
  132. typedef int UBYTEPARAM;
  133. #endif
  134.  
  135.  
  136. typedef unsigned UNSIGNED;
  137. typedef unsigned long ULONG;
  138. typedef unsigned char UBYTE;
  139. typedef unsigned short USHORT;
  140.  
  141. /* Function pointer types */
  142. typedef char  (*CHARFUNPTR)();
  143. typedef short (*SHORTFUNPTR)();
  144. typedef int   (*INTFUNPTR)();
  145. typedef LONG  (*LONGFUNPTR)();
  146. typedef ULONG (*ULONGFUNPTR)();
  147. typedef VOID  (*VOIDFUNPTR)();
  148. #ifndef SCO
  149. typedef BOOLPARAM  (*BOOLFUNPTR)();
  150. typedef ADDRESS  (*ADDRFUNPTR)();
  151. #else
  152. typedef char  (*BOOLFUNPTR)();
  153. typedef char *  (*ADDRFUNPTR)();
  154. #endif
  155.  
  156. /* Constants */
  157. #define STDIN (0)
  158. #define STDOUT (1)
  159. #define STDERR (2)
  160. #define YES (1)
  161. #define NO (0)
  162. #define BUFSIZE (512)
  163. #define BWRITE (-1)
  164. #ifdef WINNT
  165. #define READ_BIN "rb"
  166. #else
  167. #define READ_BIN "r"
  168. #endif
  169. #define READ_TEXT "r"
  170. #define READ READ_BIN
  171. #ifdef WINNT
  172. #define WRITE_BIN "wb"
  173. #else
  174. #define WRITE_BIN "w"
  175. #endif
  176. #define WRITE_TEXT "w"
  177. #define WRITE WRITE_TEXT
  178. #define READ_WRITE "????" 
  179. #define APPEND "a"
  180. #define BYTMASK (0377)
  181.  
  182. /* Macros */
  183. #define FOREVER for (;;)
  184. #ifndef    DV_VIABS /* to be phased out */
  185. #define DV_VIABS(x) ((x) < 0 ? -(x) : (x))
  186. #endif
  187. #ifndef    ABS /* V.I. MACRO, not a function, like S_FABS, which is below */
  188. #define ABS(x) ((x) < 0 ? -(x) : (x))
  189. #endif
  190. /* define macros to use instead of max and min */
  191. #define S_MAX(x, y) (((x) < (y)) ? (y) : (x))
  192. #define S_MIN(x, y) (((x) < (y)) ? (x) : (y))
  193.  
  194. /* Before we used to make our own ctype macros in case the system ones */
  195. /* weren't defined.  THIS IS NOW WRONG. Ctype macros (e.g. isprint, isalpha) */
  196. /* (Our versions: S_ISPRINT, S_ISALPHA) are defined in dvctype.h */
  197.  
  198. /* VI's access to system routines */
  199.  
  200. /* Standard I/O */
  201. #define S_FLUSHCHAR fflush(stdout)
  202. #define S_FLUSHC fflush
  203. #define S_FOPEN fopen
  204. #define S_FCREATE fopen
  205. #define S_FCLOSE fclose
  206.  
  207. #ifdef WINNT
  208. #define S_POPEN _popen
  209. #define S_PCLOSE _pclose
  210. #else
  211. #define S_POPEN popen
  212. #define S_PCLOSE pclose
  213. #endif
  214.  
  215. #if defined(MASSCOMP)
  216. #define S_VFPRINTF VIvfprintf
  217. #else
  218. #define S_VFPRINTF vfprintf
  219. #endif
  220.  
  221. #define S_GETCHAR getchar
  222. #define S_PUTCHAR putchar
  223. #define S_FGETC fgetc
  224. #define S_GETC getc
  225. #define S_UNGETC ungetc
  226. #define S_FPUTC fputc
  227. #define S_PUTC putc
  228. #define S_SCANF scanf
  229. #define S_FSCANF fscanf
  230. #define S_SSCANF sscanf
  231. #define S_PRINTF printf
  232. #define S_FPRINTF fprintf
  233. #define S_SPRINTF sprintf
  234. #define S_FGETS fgets 
  235. #define S_GETS gets 
  236. #define S_FPUTS fputs 
  237. #define S_PUTS puts
  238.  
  239. #define S_FREAD fread 
  240. #ifdef INT_IS_16_BITS
  241. #  define S_FREADL VIfreadl 
  242. #else /* Int is 32 bits */
  243. #  define S_FREADL fread 
  244. #endif
  245.  
  246. #define S_SETBUF setbuf
  247.  
  248. #define S_FWRITE fwrite
  249. #ifdef INT_IS_16_BITS
  250. #  define S_FWRITEL VIfwritel
  251. #else /* Int is 32 bits */
  252. #  define S_FWRITEL fwrite
  253. #endif
  254.  
  255. /* C Library Functions (and extensions) */
  256. #define S_ATOI atoi
  257. #define S_ATOL atol
  258. #define S_ATOF atof
  259. #ifdef DYNAGRAPHX
  260. #define S_ALLOC XtMalloc
  261. #define S_REALLOC XtRealloc
  262. #define S_FREE XtFree 
  263. #else
  264. #define S_ALLOC VUmalloc
  265. #define S_REALLOC VUrealloc
  266. #define S_FREE VUfree 
  267. #endif
  268. #define S_EXIT VUexit
  269. #define S_GETENV getenv
  270. #define S_PUTENV putenv
  271. #ifdef VMS
  272. #define S_QSORT VIqsort
  273. #else
  274. #define S_QSORT qsort
  275. #endif
  276. #define S_SETJMP setjmp
  277. #define S_LONGJMP longjmp
  278. #define VI_SIGNAL signal
  279. #define S_STRCAT strcat
  280. #define S_STRCMP VIstrcmp
  281. #define S_STRCPY strcpy
  282. #define S_STRLEN strlen
  283. #define S_STRTOL strtol
  284. #define S_STRNCAT strncat
  285. #define S_STRNCMP strncmp
  286. #define S_STRNCPY strncpy
  287. #define S_MEMCMP memcmp
  288.  
  289. #ifdef __STDC__
  290. #define S_VA_PARAM va_alist
  291. #define S_VA_DECL  va_dcl
  292. /* #define S_VA_PARAM ... */
  293. /* #define S_VA_DECL  */
  294. #define S_VA_START(a,b) va_start(a,b)
  295. #else
  296. #define S_VA_PARAM va_alist
  297. #define S_VA_DECL  va_dcl
  298. #define S_VA_START(a,b) va_start(a)
  299. #endif
  300.  
  301. #if defined(SOLARIS) || defined(WINNT)
  302. #define S_BCOPY(a,b,c) memcpy(b,a,c)
  303. #define S_BZERO bzero
  304. #else
  305. #if defined(VMS)
  306. #define S_BCOPY VIbcopy 
  307. #define S_BZERO VIbzero
  308. #else
  309. #define S_BCOPY bcopy 
  310. #define S_BZERO bzero
  311. #endif
  312. #endif
  313. /* This is dependent on which system header file is used*/
  314. #ifdef HAS_STRING_H 
  315. #define S_STR_INDEX strchr
  316. #define S_STR_RINDEX strrchr
  317. #else
  318. #define S_STR_INDEX index
  319. #define S_STR_RINDEX rindex
  320. #endif
  321. #define S_STRTOK strtok
  322. #define S_SYSTEM system
  323.  
  324. /* System Calls */
  325. #define S_OPEN open 
  326. #define S_CLOSE close 
  327. #define S_READ read
  328. #define S_WRITE write
  329. #ifndef VMS /* No equivalent on VMS. */
  330. #define S_IOCTL ioctl
  331. #endif
  332. #define S_STAT stat 
  333. #define S_FSTAT fstat 
  334. #define S_GETCWD getcwd 
  335.  
  336. #ifdef HAS_SELECT_FUNC
  337. #define S_SELECT select 
  338. #endif
  339. #define S_UNLINK unlink
  340.  
  341. /* Mathematical Functions */
  342. #define S_ABS DV_VIABS
  343. #define S_ATAN atan
  344. #define S_ATAN2 atan2
  345. #define S_CEIL ceil 
  346. #define S_COS cos 
  347. #define S_FABS fabs
  348. #define S_FLOOR floor 
  349. #define S_LOG10 log10 
  350. #define S_POW pow 
  351. #define S_SIN sin 
  352. #define S_SQRT sqrt 
  353. #define S_TAN tan 
  354.  
  355.  
  356.  
  357. /* FUNCTION DECLARATIONS--these collapse to standard C functions
  358.  * If you get "redeclaration" errors when linking, it is safe to 
  359.  * comment out the appropriate function declaration. 
  360.  */
  361.  
  362. /* FUNCTION DECLARATIONS--these collapse to dataviews functions */
  363. #ifdef __cplusplus
  364. extern "C" {
  365. #endif /* __cplusplus */
  366.  
  367. #if defined(SYSV) || defined(VMS) || defined(WINNT)
  368. /* strtok is not in strings.h on the sun */
  369. #ifdef  _DLL
  370. __declspec(dllimport) char *strtok V_P_((char *s1, const char *s2));
  371. #else   /* ndef _DLL */
  372. char *strtok V_P_((char *s1, const char *s2));
  373. #endif  /* _DLL */
  374. #endif
  375.  
  376.   ADDRESS _CDECL VUmalloc V_P_(( LONG ));
  377.   ADDRESS _CDECL VUrealloc V_P_(( ADDRESS, LONG ));
  378.   VOID _CDECL VUfree V_P_(( ADDRESS ));
  379.   VOID _CDECL VUexit V_P_(( int ));
  380.   int _CDECL VIstrcmp V_P_(( char *, char * ));
  381. #ifdef INT_IS_16_BITS
  382.   LONG _CDECL VIfreadl V_P_(( ADDRESS, int, LONG, FILE * ));
  383.   LONG _CDECL VIfwritel V_P_(( ADDRESS, int, LONG, FILE * ));
  384. #endif
  385. #ifdef VMS
  386.   int _CDECL VIbcopy V_P_(( char *, char *, int )); 
  387. #endif
  388.   
  389. #ifdef __cplusplus
  390. }
  391. #endif /* __cplusplus */
  392.  
  393. /* Exit codes for calling S_EXIT() or return from main program */
  394. #ifdef    VMS
  395. #define    EXIT_OK        1
  396. #define    EXIT_ERR    2
  397. #else
  398. #define    EXIT_OK        0
  399. #define    EXIT_ERR    1
  400. #endif    /* VMS */
  401.  
  402. /* The keywords "near" and "far" are defined out of existance for
  403. |  compilers that don't need memory models.
  404. */
  405.  
  406. #ifndef    MEMORY_MODEL
  407. #define    near    /* for near pointers */
  408. #define    far    /* for far pointers */
  409. #endif    /* MEMORY_MODEL */
  410.  
  411. #ifdef DV_DEV_COMP
  412. #include "vi/sysfuns.h"
  413. #endif
  414.  
  415. /* Backward compatibility of upgraded typedefs and defines */
  416. #ifdef DV_OLD_NAMES
  417. #define abs DV_VIABS 
  418. #define BOOL DV_BOOL 
  419. #define BYTE char
  420. #endif /* DV_OLD_NAMES */
  421.  
  422. #endif    /* _STD_H_ */
  423.